/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2023. All rights reserved.
 *
 */

import fse from 'fs-extra';

export const HvigorNativeConfigFile = 'hvigor_native_config.json';

export const readHvigorNativeConfigFile = async (file: string): Promise<HvigorNativeConfig | undefined> => {
  if (!fse.existsSync(file)) {
    return undefined;
  }
  return fse.readJSON(file);
};

export interface HvigorNativeConfig {
  cleanCommands: string[][];
  buildCommands: string[][];
  libraries: NativeLibraries;
  buildFiles: string[];
  toolchain: NativeToolchainModel;
  extra?: string[];
}

export interface NativeLibraries {
  [key: string]: NativeLibrary;
}

export interface NativeToolchainModel {
  cCompilerExecutable: string;
  cppCompilerExecutable: string;
}

export interface NativeLibrary {
  toolchain?: string;
  abi?: string;
  artifactName?: string;
  output?: string;
  runtimeFiles?: string[];
}
